package com.zyy.study.demo;

import org.junit.Test;

public class ExceptionDemo {
    public static void main(String[] args) {
        test();
        //test2();
    }

    public static void test() throws NullPointerException {
        throw new NullPointerException();
    }
    public static void test2() throws Exception{
        throw new NullPointerException();
    }
    @Test
    public void test3(){
        for (int i = 0; i < 3; i++) {
            try {
                if (i % 2 == 0) {
                    throw new Exception(i+":这是偶数");
                }
            } catch (Exception e) {
                System.out.println(e.getMessage());
            }
        }

    }
}
